package com.example.change2;

import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.example.change2.utils.LogUtils;

import java.security.PublicKey;

public class FirstActivity extends AppCompatActivity {
    private TextView textView;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_main);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;//hellow
        });
        Button button = (Button) findViewById(R.id.buttom_1);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                shouwToast("123");
            }
        });
//        setContentView(R.layout.activity_main);
////        通过findViewById获取布局文件中的元素 返回一个View对象
//        textView = findViewById(R.id.buttom_1);
//        Button buttom_1 = (Button) findViewById(R.id.buttom_1);
////        buttom_1 = findViewById(R.id.buttom_1);
////        将View转换为Button对象，setOnClickListener注册一个监听器
//        textView.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                Toast.makeText(FirstActivity.this,"22222222",Toast.LENGTH_SHORT).show();
//            }
//        });
//        buttom_1.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                Toast.makeText(FirstActivity.this,"22222222",Toast.LENGTH_SHORT).show();
//            }
//        });
    }

    private void  shouwToast(String text){
        LogUtils.d("TAG", "====anniu: ========="+text);
        Toast.makeText(this,text,Toast.LENGTH_LONG).show();
    }
}